package com.example.repair

import androidx.core.view.isVisible
import androidx.databinding.DataBindingUtil
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.example.base.entity.RepairEntityItem
import com.example.repair.databinding.ItemRepairBinding


class RepairAdapter:BaseQuickAdapter<RepairEntityItem,BaseViewHolder>(R.layout.item_repair) {

    override fun onItemViewHolderCreated(viewHolder: BaseViewHolder, viewType: Int) {
        super.onItemViewHolderCreated(viewHolder, viewType)
        DataBindingUtil.bind<ItemRepairBinding>(viewHolder.itemView)
    }

    override fun convert(helper: BaseViewHolder, item: RepairEntityItem) {
        val binding = DataBindingUtil.getBinding<ItemRepairBinding>(helper.itemView)!!
        binding.bean=item

        binding.repairStatus.apply {
            when(item.processingStatus){
                "待处理"->{
                    binding.repairUpdate.text = "指派接单"
                    setBackgroundResource(R.drawable.bg_red)
                }
                "处理中"->{
                    binding.repairUpdate.text = "审核完成"
                    setBackgroundResource(R.drawable.bg_yellow)
                }
                "已完成"->{
                    binding.repairUpdate.isVisible = false
                    setBackgroundResource(R.drawable.bg_green)
                }
            }
        }
    }
}